home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 7 / FM Towns Free Software Collection 7.iso / taropyon / hewin / ccisrc / center02.cci < prev    next >
Text File  |  1993-11-30  |  7KB  |  275 lines

  1. /*************************************************************************
  2. *    "center02.cci" : NANNO用センター処理
  3. *************************************************************************/
  4.  
  5. #ifdef    CENTERKEY
  6. #undef    CENTERKEY
  7. #endif
  8. #ifdef    RECKEY
  9. #undef    RECKEY
  10. #endif
  11.  
  12. #define    CENTERKEY    "CENTER02"
  13. #define    RECKEY        _center02_recKey
  14.  
  15. char    *_center02_recKey;
  16.  
  17. int        _CENTER02_init()
  18. {
  19.     char    *center;
  20.  
  21.     if ( (center = NTM_centerAlloc( CENTERKEY )) != NULL )
  22.     {
  23.         NtmCenterSetName   ( center, "Sample center (type-02:nanno)");
  24.         NtmCenterSetFuncKey( center, "CENTER02");
  25.         NtmCenterSetRecKey ( center, "CENTER02");
  26.         NtmCenterSetRsPara ( center, -1, -1, -1 );
  27.         NtmCenterSetRsBreak( center, 50 );
  28.         NtmCenterSetCrWait ( center, 100 );
  29.         NtmCenterSetTel    ( center, "" );
  30.         NtmCenterSetModem1 ( center, "ATZ" );
  31.     }
  32.     return (NORMAL);
  33. }
  34.  
  35. /*************************************************************************
  36. *    ナビゲーション用初期化
  37. *************************************************************************/
  38.  
  39. int        _CENTER02_naviInit( char *ntm, char *center )
  40. {
  41. #ifndef    _NAV_IGNORE
  42.     NtmSetNaviServiceMode( ntm, 0 );    /* ナビゲーションシステムなし    */
  43. #endif
  44.     return (NORMAL);
  45. }
  46.  
  47. /*************************************************************************
  48. *    パラメータの指定
  49. *************************************************************************/
  50.  
  51. int        _CENTER02_para( char *ntm, char *center )
  52. {
  53.     char    *keyWord;
  54.     char    *id, *pw;
  55.  
  56.     keyWord = NtmCenterGetKeyWord(center);
  57.     if ( NTM_centerConfig( keyWord ) == NORMAL )
  58.     {
  59.         id  = NtmCenterGetID      ( center );
  60.         pw  = NtmCenterGetPassword( center );
  61.         if ( id[0] == 0 || pw[0] == 0 )
  62.             return (ERR);
  63.         return (NORMAL);
  64.     } else
  65.         return (ERR);
  66. }
  67.  
  68.  
  69. /*************************************************************************
  70. *    処理の中断
  71. *************************************************************************/
  72.  
  73. int        _CENTER02_abort( char *ntm, char *center )
  74. {
  75.     AplRecWrite("%s:Abort", RECKEY);
  76.     NTM_offline( ntm, DTR_OFF_TIME );
  77.     return (NORMAL);
  78. }
  79.  
  80. /*************************************************************************
  81. *    [AUTO]メニュー処理
  82. *************************************************************************/
  83.  
  84. int        _CENTER02_autoMenu( char *ntm, char *center, int x, int y)
  85. {
  86.     int        ret;
  87.     char    *obj;
  88.     char    *mnu;
  89.     char    title[128], tmp[128], tmBuf[32];
  90.     long    loginTime;
  91.  
  92.     if ( ntm == NULL || center == NULL )
  93.         return (0);
  94.     loginTime = NtmCenterGetTime(center, NTM_TIME_LOGIN );
  95.     if ( loginTime )
  96.     {    sprintf( tmp, "Login time %s ", GetAsciiTime(tmBuf,loginTime) );
  97.     } else
  98.     {    strcpy( tmp, "Login time XXXX/XX/XX XX:XX:XX");
  99.     }
  100.     obj = MNU_alloc(3);
  101.     MNU_setObj(obj, 0, MNU_MSG,  0 , tmp               , NULL, 0, NULL, NULL );
  102.     MNU_setObj(obj, 1, MNU_NOR, 'O', "OFF 終了"        , NULL, 1, NULL, NULL );
  103.     MNU_setObj(obj, 2, MNU_NOR, 'B', "OFF 強制回線切断", NULL, 2, NULL, NULL );
  104.  
  105.     sprintf( title, "MENU : %s", NtmCenterGetName(center));
  106.     mnu = MNU_open( x, y, MNUATT_EXIT, obj, title );
  107.     ret = MNU_start ( mnu );
  108.     MNU_close(mnu);
  109.     MNU_free(obj);
  110.     switch ( ret )
  111.     {
  112.         case    1:
  113.             return    NTM_callLogout( ntm );
  114.         case    2:
  115.             NTM_wait(3);
  116.             AplRecWrite("%s:Abort disconnect", RECKEY);
  117.             return    NTM_offline(ntm, DTR_OFF_TIME);
  118.     }
  119.     return (NORMAL);
  120. }
  121.  
  122. /*************************************************************************
  123. *    ログイン処理
  124. *************************************************************************/
  125.  
  126. int        _CENTER02_login( char *ntm, char *center )
  127. {
  128.     int        i, ret, retry;
  129.     char    *name, *tel, *id, *pw, *para;
  130.     int        argc;
  131.     char    *s, **argv;
  132.     long    tm;
  133.     char    *cns;
  134.     char    *mos;
  135.  
  136.     mos = NULL;
  137.     cns = NtmGetCnsPtr(ntm);
  138. #ifdef    _TAROPYON_SYSTEM
  139.     /* ログ保存行数を増やす    */
  140.     if ( CnsGet_maxLinBuf(cns) < 99999 )
  141.         CnsSet_maxLinBuf(cns,99999);
  142. #endif
  143.     _center02_recKey = NtmCenterGetRecKey(center);
  144.  
  145.     name = NtmCenterGetName    ( center );
  146.     tel  = NtmCenterGetTel     ( center );
  147.     id   = NtmCenterGetID      ( center );
  148.     pw   = NtmCenterGetPassword( center );
  149.     if ( tel[0] == 0 || id[0] == 0 || pw[0] == 0 )
  150.     {
  151.         _ntm_errmsg_no_setup_id_and_pw();
  152.         if ( _CENTER02_para( ntm, center ) )
  153.             return (ERR);
  154.         id  = NtmCenterGetID      ( center );
  155.         pw  = NtmCenterGetPassword( center );
  156.         tel = NtmCenterGetTel     ( center );
  157.     }
  158.  
  159.     _ntm_dspmsg_dial_start( name, tel, cns );
  160.  
  161.     AplRecWrite("%s:Dial start tel.%s", RECKEY, tel );
  162.     if ( ntm_dialStart( ntm, tel ) != NORMAL )
  163.     {
  164. ABORT:    _CENTER02_abort( ntm, center );
  165.         if ( mos )    MOS_pop(mos);
  166.         return (ERR);
  167.     }
  168.  
  169.     mos = MOS_push();
  170.     MOS_curType(MOSCUR_TIME);
  171.     MOS_CON();
  172.     AplRecWrite("%s:Connect", RECKEY );
  173.  
  174.     NTM_wait(1);
  175.     ret = NTM_waitStr( ntm, 30, "HIT RETURN KEY>", NULL);
  176.     if ( ret == NTM_WAIT_CANCEL )
  177.         goto    ABORT;
  178.     NTM_rsPuts(ntm,"\r");
  179.     NTM_wait(1);
  180.  
  181.     ret = NTM_waitStr( ntm, 30, "User ID=", NULL );
  182.     if ( ret == NTM_WAIT_CANCEL )
  183.         goto    ABORT;
  184.     NTM_wait(1);
  185.     NTM_rsPuts( ntm, id );    NTM_rsPuts(ntm,"\r");
  186.  
  187.     ret = NTM_waitStr( ntm, 30, "Password=", NULL);
  188.     if ( ret == NTM_WAIT_CANCEL )
  189.         goto    ABORT;
  190.     NTM_wait(1);
  191.     NTM_rsPuts( ntm, pw );    NTM_rsPuts(ntm,"\r");
  192.  
  193.     /* ログイン時間    */
  194.     time(&tm);
  195.     NtmCenterSetTime( center, NTM_TIME_LOGIN, tm );
  196.     AplRecWrite("%s:Login successful", RECKEY );
  197.     MOS_pop(mos);
  198.  
  199.     return (NORMAL);
  200. }
  201.  
  202.  
  203. /*************************************************************************
  204. *    ログアウト処理
  205. *************************************************************************/
  206.  
  207. int        _CENTER02_logout( char *ntm, char *center )
  208. {
  209.     int        ret;
  210.     long    tm;
  211.  
  212.     time(&tm);
  213.     NtmCenterSetTime( center, NTM_TIME_LOGOUT, tm );
  214.     AplRecWrite("%s:Logout", RECKEY);
  215.     NTM_wait(1);
  216.     NTM_rsPuts( ntm, "OFF\r");
  217.     NTM_waitInstr( ntm, 30, "NO CARRIER", NULL );
  218.     NTM_offline(ntm, DTR_OFF_TIME);
  219.     AplRecWrite("%s:Disconnect", RECKEY);
  220.     return (NORMAL);
  221. }
  222.  
  223. /*************************************************************************
  224. *    受信行のチェック
  225. *************************************************************************/
  226.  
  227. int        _CENTER02_lineCheck( char *ntm, char *buf )
  228. {
  229.     return (NORMAL);
  230. }
  231.  
  232. /*************************************************************************
  233. *    フィルタ設定メニュー
  234. *************************************************************************/
  235.  
  236. int        _CENTER02_filterMenu( char *ntm, int x, int y )
  237. {
  238.     return    NtmUsr_filterMenu( ntm, x, y );
  239. }
  240.  
  241. /*************************************************************************
  242. *    入力文字列の送信
  243. *************************************************************************/
  244.  
  245. int        _CENTER02_inputCheck( char *ntm, char *s )
  246. {
  247.     NTM_rsPuts( ntm, s    );
  248.     NTM_rsPuts( ntm, "\r" );
  249.     return (NORMAL);
  250. }
  251.  
  252.  
  253. int        CCI_dspCenter02Stt()
  254. {
  255.     char    *center;
  256.     char    *name;
  257.     long    loginTime, logoutTime;
  258.     char    t1[32], t2[32];
  259.  
  260.     if ( (center = NTM_getCenter(CENTERKEY)) == NULL )
  261.         return (ERR);
  262.     name = NtmCenterGetName(center);
  263.     loginTime  = NtmCenterGetTime( center, NTM_TIME_LOGIN );
  264.     logoutTime = NtmCenterGetTime( center, NTM_TIME_LOGOUT );
  265.     DLG_tmpMsgBox( DLGPOS_CENTER_OF_SCN, DLGPOS_CENTER_OF_SCN, 
  266.         C_MBLACK, C_DLGBASE, COLMIX(C_INFO,C_GRAY),
  267.         "  センター名 : %s\n  Login time       %s  \n  Last logout time %s  ",
  268.         name, GetAsciiTime(t1, loginTime), GetAsciiTime(t2,logoutTime) );
  269.     return (NORMAL);
  270. }
  271.  
  272.  
  273. #undef    CENTERKEY
  274. #undef    RECKEY
  275.